{% extends "master.html" %}

{% block title %}Миний номын сан{% endblock %}

{% block script %}
<script type="text/javascript">
function editBook(id)
{
	window.location.href = '/save_book?id=' + id;
}

function deleteBook(id)
{
	window.location.href = '/delete_book?id=' + id;
}
</script>
{% endblock %}

{% block content %}
	{% if user %}
		<table align="center">
			<tbody>
				<tr>
					<td><center><strong><p>Миний номын сан</p></strong></center></td>
				</tr>
			</tbody>
		</table>
		{% if author_list %}
			<table align="center">
				<tbody>
					<tr>
						<td></td>
						<td><input type="button" value="Ном оруулах" onclick="redirect(3)" /></td>
					</tr>
				</tbody>
			</table>
			{% if book_list %}
				<table align="center">
					<tbody>
						<tr>
							<td colspan="2"><center><strong><p>Миний оруулсан номууд</p></strong></center></td>
						</tr>
						{% for book in book_list %}
							<tr bgcolor="#eee">
								<td>Гарчиг: </td>
								<td>{{ book.title }}</td>
							</tr>
							<tr>
								<td>ISBN: </td>
								<td>{{ book.isbn }}</td>
							</tr>
							<tr>
								<td>Бичигдсэн хэл: </td>
								<td>{{ book.language.language }}</td>
							</tr>
							<tr>
								<td>Бичигдсэн он: </td>
								<td>{{ book.year }}</td>
							</tr>
							<tr>
								<td>Нийт хуудас: </td>
								<td>{{ book.total_pages }}</td>
							</tr>
							<tr>
								<td>Үнэлгээ: </td>
								<td>{{ book.rating|default:"Үнэлгээ оруулаагүй байна" }}</td>
							</tr>
							<tr>
								<td>Үнэ: </td>
								<td>{{ book.price }} {{ book.currency.currency }}</td>
							</tr>
							<tr>
								<td>Агуулга: </td>
								<td>{{ book.content }}</td>
							</tr>
							<tr>
								<td></td>
								<td>
									<input type="button" value="Засах" onclick="editBook({{ book.key.id }})" />
									<input type="button" value="Устгах" onclick="deleteBook({{ book.key.id }})" />
								</td>
							</tr>
						{% endfor %}
					</tbody>
				</table>
			{% endif %}
		{% endif %}
	{% endif %}
{% endblock %}

{% block sidebar %}{% include "sidebar.html" %}{% endblock %}